#pragma once
#include "AnimationCommon.h"

typedef int ParentIndex;
typedef Eigen::Vector3f WorldPos;

class CSkeletonController
{
public:
	CSkeletonController() = default;
	CSkeletonController(const std::string& vFilePath);
	~CSkeletonController() = default;

	bool initSkeletonByFile(const std::string& vFilePath);
	bool pumpNextPose(std::vector<Eigen::Matrix4f>& voSkeletonTransfer);
	bool pumpNextPose(std::vector<std::pair<ParentIndex, WorldPos>>& voSkeletonInfo);
	void resetPose();

	int getBoneCount() const { return m_Skeleton.size(); }
	int getParentIndexAt(int vIndex) const;
	const Eigen::Vector3f getInitialBoneWorldPos(int vIndex) const;
	const Eigen::Matrix4f getWorldToLocalTransfer(int vIndex) const;
	
private:
	//FRIEND_TEST(TestSkeletonController, TestGenerateData);
	void __generateSkeleton(const std::vector<std::string>& vAllFileStr);
	void __generateAllPose(const std::vector<std::string>& vAllFileStr);
	void __generateInitialData();

	std::vector<SSkeletonDefinition> m_Skeleton;
	std::vector<std::vector<Eigen::Matrix4f>> m_AllPose;
	std::vector<Eigen::Vector3f> m_InitialWorldPos;
	std::vector<Eigen::Matrix4f> m_WorldToLocalTransfer;
	int m_CurrentPoseIndex = -1;
};